package com.wlgzs.booksystem.enums;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
public class Result<T> {

    /**
     * 状态码
     */
    private int code;
    /**
     * 状态信息
     */
    private String msg;
    /**
     * 返回数据
     */
    private Object data;

    /**
     * 返回数据集合
     */
    private List<Object> dataList;

    public Result() {}

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(ResultCodeEnum resultCodeEnum) {
        this.code = resultCodeEnum.getCode();
        this.msg = resultCodeEnum.getMsg();
    }

    public Result(ResultCodeEnum resultCodeEnum , Object data) {
        this(resultCodeEnum);
        this.data = data;
    }

    public Result(ResultCodeEnum resultCodeEnum , List<Object> dataList) {
        this(resultCodeEnum);
        this.dataList = dataList;
    }
}
